<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>配送员注册</title>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<c:set var="bp" value="<%=basePath%>"></c:set>
<link rel="stylesheet" type="text/css" href="${bp}/static/css/htmleaf-demo.css"/>
<link rel="stylesheet" type="text/css" href="${bp}/static/css/normalize.css"/>
<link rel="stylesheet" type="text/css" href="${bp}/static/css/login.css"/>
<script type="text/javascript" src="${bp}/static/js/jquery.js"></script>
<script type="text/javascript" src="${bp}/static/js/login.js"></script>
	<%--实时校验注册信息--%>
	<script>
		// 电话校验
		function uTel_check() {
			//判断手机号是否已经注册
			var phone= $.trim($('#dtel').val());
			console.log(phone);
			$.ajax({
				url: "getcourierbydtel.action",
				type: "post",
				data:{
					"dtel":phone,
				},
				success:function (result){
					console.log(result);
					var re1 = JSON.parse(result);
					console.log(re1);
					if (re1==false){
						//正则表达式，判断电话号码的格式正确性
						var phone1 = /^[1][3,4,5,7,8][0-9]{9}$/;
						if (phone == "") {
							document.getElementById("dteltishi").innerHTML = "电话不能为空";
							document.getElementById("dteltishi").style.color = "red";
							return false;
						} else {
							document.getElementById("dteltishi").innerHTML = "请输入你的常用手机号，我们会严格保密";
							document.getElementById("dteltishi").style.color = "#999999";
							if (!phone1.test(phone)) {
								document.getElementById("dteltishi").innerHTML = "手机号码格式不正确，请重新输入";
								document.getElementById("dteltishi").style.color = "red";
								document.getElementById("dtel").value = " ";
								return false;
							} else {
								document.getElementById("dteltishi").innerHTML = "手机号码格式正确";
								document.getElementById("dteltishi").style.color = "#999999";
								return true;
							}
						}
						$("#dteltishi").html("电话号可以使用");
					}else{
						$("#dteltishi").html("电话号已经注册,请换新号注册");
						document.getElementById("dteltishi").style.color = "red";
						$('#dtel').val("");
					}
				}
			});
		}
		// 得到焦点，提示归零
		function uTel_check2() {
			$("#dteltishi").html("");
		}
	</script>

</head>

<body>
	<div class="htmleaf-container">
		<div id="wrapper" class="login-page">
		  <div id="login_form" class="form">
		    <form class="login-form" action="regist.action" method="post">
		   <h2 style="position: absolute; left: 20px; top: 0; background-color: #2aabd2">返回</h2> <h3 style="text-align: center;margin-top:0">配送员注册</h3>
		      <input type="text" placeholder="电话号码" id="dtel" name="dtel" required="required" onblur="uTel_check()" onfocus="uTel_check2()"/>
				<p id="dteltishi"></p>
		      <input type="password" placeholder="密码" id="dpass" name="dpass" required="required"/>
				<input type="password" placeholder="确认密码" id="redpass" name="redpass" required="required"/>

		      <input type="text" placeholder="身份证号" id="didcard" name="didcard" required="required"/>
				<input type="text" placeholder="真实姓名" id="dname" name="dname" required="required"/>
	      <input type="text" placeholder="性别" id="dsex"  name="dsex"/>

		      <input type="text" placeholder="年龄" id="dage"  name="dage"/>
				<input type="file" placeholder="请上传您的体检报告" name="ddate">
		      <input style="background-color: #5cb85c" value="注	册"  type="submit">
		      <p class="message">已经有了一个账户? <a id="toregist" href="tologin">立刻登录</a></p>
		    </form>
		  </div>
		</div>
	</div>
</body>
</html>